<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>彩色便签</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            overflow: hidden;
            position: relative;
        }

        .sticky-note {
            position: absolute;
            width: 280px;
            min-height: 200px;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
            cursor: move;
            user-select: none;
            transition: transform 0.1s ease, box-shadow 0.2s ease;
            z-index: 1;
            opacity: 0;
            transform: scale(0.5) rotate(0deg);
            animation: appearNote 0.6s ease-out forwards;
        }

        @keyframes appearNote {
            from {
                opacity: 0;
                transform: scale(0.5) rotate(-10deg);
            }
            to {
                opacity: 1;
                transform: scale(1) rotate(var(--note-rotate, 0deg));
            }
        }

        .sticky-note:hover {
            transform: scale(1.02) rotate(var(--note-rotate, 0deg));
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
            z-index: 10;
        }

        .sticky-note.dragging {
            cursor: grabbing;
            opacity: 0.9;
            z-index: 1000;
        }

        .note-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        }

        .note-buttons {
            display: flex;
            gap: 5px;
        }

        .note-btn {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            border: none;
            cursor: pointer;
            transition: transform 0.2s;
        }

        .note-btn:hover {
            transform: scale(1.2);
        }

        .note-close {
            background-color: #ff5f57;
        }

        .note-minimize {
            background-color: #ffbd2e;
        }

        .note-maximize {
            background-color: #28ca42;
        }

        .note-content {
            font-size: 16px;
            line-height: 1.6;
            color: #333;
            word-wrap: break-word;
        }

        /* 不同颜色的便签 */
        .note-white {
            background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
            color: #333;
        }

        .note-pink {
            background: linear-gradient(135deg, #ffe0e6 0%, #ffb3c6 100%);
            color: #333;
        }

        .note-green {
            background: linear-gradient(135deg, #e0f7e0 0%, #b3ffb3 100%);
            color: #333;
        }

        .note-blue {
            background: linear-gradient(135deg, #e0f0ff 0%, #b3d9ff 100%);
            color: #333;
        }

        .note-orange {
            background: linear-gradient(135deg, #ffe6cc 0%, #ffcc99 100%);
            color: #333;
        }

        .note-purple {
            background: linear-gradient(135deg, #f0e0ff 0%, #d9b3ff 100%);
            color: #333;
        }

        .note-yellow {
            background: linear-gradient(135deg, #fffacd 0%, #fff44f 100%);
            color: #333;
        }

        .play-button {
            width: 60px;
            height: 60px;
            background: #888;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 20px auto;
            cursor: pointer;
            transition: all 0.3s;
        }

        .play-button:hover {
            background: #666;
            transform: scale(1.1);
        }

        .play-icon {
            width: 0;
            height: 0;
            border-left: 20px solid white;
            border-top: 12px solid transparent;
            border-bottom: 12px solid transparent;
            margin-left: 5px;
        }
    </style>
</head>
<body>
    <!-- 便签容器将由JavaScript动态生成 -->

    <script>
        // 便签内容数据
        const notesData = [
            { text: "今天过得开心", color: "note-white" },
            { text: "今天过得开心啦", color: "note-pink" },
            { text: "天冷了,多穿衣服", color: "note-blue" },
            { text: "早点休息", color: "note-purple" },
            { text: "保持微笑呀", color: "note-yellow" },
            { text: "我想你了", color: "note-pink" },
            { text: "记得吃水果", color: "note-green" },
            { text: "每天都要元气满满", color: "note-green" },
            { text: "期待下一", color: "note-orange" },
            { text: "愿所有烦恼都消失", color: "note-white", hasPlayButton: true },
            { text: "保持好心情", color: "note-blue" },
            { text: "别熬夜", color: "note-purple" },
            { text: "多喝水哦~", color: "note-blue" },
            { text: "好好爱自己", color: "note-pink" },
            { text: "梦想成真", color: "note-yellow" },
            { text: "保持微笑对", color: "note-white" },
            { text: "今天过得开心", color: "note-orange" },
            { text: "保持微笑呀", color: "note-green" },
            { text: "早点休息", color: "note-white" },
            { text: "我想你了", color: "note-purple" },
            { text: "记得吃水果", color: "note-pink" },
            { text: "天冷了,多穿衣服", color: "note-blue" },
            { text: "多喝水哦~", color: "note-yellow" },
            { text: "别熬夜", color: "note-orange" },
            { text: "好好爱自己", color: "note-green" },
            { text: "每天都要元气满满", color: "note-purple" },
            { text: "今天过得开心", color: "note-white" },
            { text: "保持微笑呀", color: "note-pink" },
            { text: "早点休息", color: "note-blue" },
            { text: "我想你了", color: "note-orange" },
            { text: "记得吃水果", color: "note-green" }
        ];

        // 创建便签
        function createStickyNote(note, index) {
            const noteElement = document.createElement('div');
            noteElement.className = `sticky-note ${note.color}`;
            noteElement.id = `note-${index}`;
            
            // 随机位置
            const maxX = window.innerWidth - 300;
            const maxY = window.innerHeight - 250;
            const randomX = Math.random() * maxX;
            const randomY = Math.random() * maxY;
            const randomRotate = (Math.random() - 0.5) * 4; // -2 到 2 度的随机旋转
            
            noteElement.style.left = `${randomX}px`;
            noteElement.style.top = `${randomY}px`;
            noteElement.style.setProperty('--note-rotate', `${randomRotate}deg`);
            noteElement.dataset.rotate = randomRotate; // 保存旋转角度
            
            // 特殊处理：包含播放按钮的便签
            let contentHTML = '';
            if (note.hasPlayButton) {
                contentHTML = `
                    <div class="note-header">
                        <div class="note-buttons">
                            <button class="note-btn note-close"></button>
                            <button class="note-btn note-minimize"></button>
                            <button class="note-btn note-maximize"></button>
                        </div>
                    </div>
                    <div class="note-content">${note.text}</div>
                    <div class="play-button">
                        <div class="play-icon"></div>
                    </div>
                `;
            } else {
                contentHTML = `
                    <div class="note-header">
                        <div class="note-buttons">
                            <button class="note-btn note-close"></button>
                            <button class="note-btn note-minimize"></button>
                            <button class="note-btn note-maximize"></button>
                        </div>
                    </div>
                    <div class="note-content">${note.text}</div>
                `;
            }
            
            noteElement.innerHTML = contentHTML;
            
            // 添加拖拽功能
            makeDraggable(noteElement);
            
            document.body.appendChild(noteElement);
            
            // 动画完成后，移除动画属性，使用正常的 transform
            noteElement.addEventListener('animationend', () => {
                noteElement.style.transform = `rotate(${randomRotate}deg)`;
            });
        }

        // 实现拖拽功能
        function makeDraggable(element) {
            let isDragging = false;
            let startX = 0;
            let startY = 0;
            let initialX = 0;
            let initialY = 0;

            element.addEventListener('mousedown', dragStart);
            document.addEventListener('mousemove', drag);
            document.addEventListener('mouseup', dragEnd);

            function dragStart(e) {
                if (e.target.classList.contains('note-btn')) {
                    return; // 如果点击的是按钮，不触发拖拽
                }
                
                if (e.target === element || element.contains(e.target)) {
                    isDragging = true;
                    element.classList.add('dragging');
                    
                    const rect = element.getBoundingClientRect();
                    startX = e.clientX;
                    startY = e.clientY;
                    initialX = rect.left;
                    initialY = rect.top;
                }
            }

            function drag(e) {
                if (isDragging) {
                    e.preventDefault();
                    const dx = e.clientX - startX;
                    const dy = e.clientY - startY;
                    
                    const rotate = element.dataset.rotate || 0;
                    element.style.left = `${initialX + dx}px`;
                    element.style.top = `${initialY + dy}px`;
                    element.style.transform = `rotate(${rotate}deg)`;
                    element.style.setProperty('--note-rotate', `${rotate}deg`);
                }
            }

            function dragEnd(e) {
                if (isDragging) {
                    isDragging = false;
                    element.classList.remove('dragging');
                }
            }
        }

        // 初始化所有便签 - 逐个显现
        function initNotes() {
            notesData.forEach((note, index) => {
                // 每个便签延迟显示，间隔150毫秒
                setTimeout(() => {
                    createStickyNote(note, index);
                }, index * 150);
            });
        }

        // 页面加载完成后初始化
        window.addEventListener('DOMContentLoaded', initNotes);

        // 窗口大小改变时重新调整位置
        window.addEventListener('resize', () => {
            const notes = document.querySelectorAll('.sticky-note');
            notes.forEach(note => {
                const rect = note.getBoundingClientRect();
                if (rect.right > window.innerWidth) {
                    note.style.left = `${window.innerWidth - rect.width - 20}px`;
                }
                if (rect.bottom > window.innerHeight) {
                    note.style.top = `${window.innerHeight - rect.height - 20}px`;
                }
            });
        });
    </script>
</body>
</html>

